﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

using Emgu.CV;
using Emgu.CV.CvEnum;
using Emgu.CV.Features2D;
using Emgu.CV.Structure;
using Emgu.CV.Util;
using Emgu.CV.WPF;

namespace jsmag
{



    public static class ImagesLoader
    {
        public static List<Image<Gray, Byte>> loadImages(String folderName)
        {
            //Image<Gray, Byte> bum = new Image<Gray, Byte>(
            List<Image<Gray, Byte>> Images = new List<Image<Gray, Byte>>();
            DirectoryInfo ImageDir = new DirectoryInfo(folderName);
            foreach (FileInfo robotImageFile in ImageDir.GetFiles("*.png"))
            {
                // Uri uri = new Uri(robotImageFile.FullName);
                //Images.Add(new Image<Gray, Byte>(uri.ToString()));

                //  Uri uri = new Uri(robotImageFile.FullName);
                Images.Add(new Image<Gray, Byte>(robotImageFile.FullName));
            }
            return Images;
        }


        public static String loadFolderName(bool isInput)
        {
            String folderName = null;
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            if (isInput)
            {
                dlg.FileName = "Kliknij na plik w folderze, który chcesz badać"; // Default file name 
            }
            else
            {
                dlg.FileName = "Kliknij na plik w folderze, w którym chcesz zapisać wyniki";
            }

            Nullable<bool> result = dlg.ShowDialog();

            if (result == true)
            {
                String pomocnik = dlg.FileName;
                int last_slash_index = pomocnik.LastIndexOf('\\');
                folderName = pomocnik.Substring(0, last_slash_index);
            }
            return folderName;
        }
    }
}


 